import type { Metadata } from 'next'; import Link from 'next/link'; import { notFound, permanentRedirect } from 'next/navigation'; import { ExternalLink } from 'lucide-react'; import { GraphLink } from '@/components/graph/graph-link'; import { PageHeader, Section, KV, Note } from '@/components/ui/section'; import { Badge, ClaimBadge, MatchBadge, StatusBadge } from '@/components/ui/badge'; import { EmptyState } from '@/components/ui/empty-state'; import { Freshness } from '@/components/ui/freshness'; import { SourceBadge } from '@/components/ui/source-badge'; import { JsonView } from '@/components/ui/json-view'; import { PublicationList } from '@/components/data/publication-list'; import { Pager } from '@/components/ui/pager'; import { getTrialByNct, trialConditionsFor, trialInterventionsFor, trialLocationsByCountry } from '@/lib/queries/trials'; import { publicationsForTrial, publicationsForTrialCount, PUBLICATION_PAGE_SIZE } from '@/lib/queries/publications'; import { fmtDate, fmtInt, humanize, phaseLabel } from '@/lib/format'; import { pageInfo } from '@/lib/pagination'; import { int, type SP } from '@/lib/search-params'; export const revalidate = 3600; export async function generateMetadata({ params }: { params: Promise<{ nct: string }> }): Promise { const t = await getTrialByNct((await params).nct); return t ? { title: `${t.nct_id} — ${t.brief_title}`, description: t.brief_summary ? t.brief_summary.slice(0, 160) : `${t.nct_id}: status, phase, conditions, interventions, locations and references.`, alternates: { canonical: `/trial/${t.nct_id}` } } : { title: 'Trial' }; } export default async function TrialPage({ params, searchParams }: { params: Promise<{ nct: string }>; searchParams: Promise }) { const { nct } = await params; const t = await getTrialByNct(nct); if (!t) notFound(); if (t.nct_id !== nct) permanentRedirect(`/trial/${t.nct_id}`); const sp = await searchParams; const pubTotal = await publicationsForTrialCount(t.nct_id); const pp = pageInfo(int(sp, 'pPage', 1, 1, 100_000), PUBLICATION_PAGE_SIZE, pubTotal); const [conditions, interventions, locations, pubs] = await Promise.all([trialConditionsFor(t.id), trialInterventionsFor(t.id), trialLocationsByCountry(t.id), pubTotal ? publicationsForTrial(t.nct_id, { page: pp.page, pageSize: pp.pageSize }) : Promise.resolve([])]); const elig = t.eligibility ?? {}; const eligText = typeof elig.criteria === 'string' ? elig.criteria : typeof elig.eligibilityCriteria === 'string' ? elig.eligibilityCriteria : null; return (
{t.nct_id} {t.id} {t.acronym ? {t.acronym} : null} {t.phases.length ? {t.phases.map(phaseLabel).join(' / ')} : null} {t.has_results ? Results posted : null} ClinicalTrials.gov
{t.why_stopped ? Why stopped (as posted): {t.why_stopped} : null}
{t.brief_summary ? (

{t.brief_summary}

) : null}
{conditions.length ? (
{conditions.map((c) => ( ))}
Condition (as posted) Mapped entity Match Confidence
{c.condition_text} {c.cancer_slug ? ( {c.cancer_name} ) : ( — )} {c.confidence != null ? c.confidence.toFixed(2) : '—'}
) : t.conditions.length ? (
    {t.conditions.map((c) => (
  • {c}
  • ))}
) : ( No condition recorded. )}
{interventions.length ? (
{interventions.map((i) => ( ))}
Intervention Type Mapped drug Match
{i.name} {i.intervention_type ? {humanize(i.intervention_type)} : '—'} {i.drug_slug ? ( {i.drug_name} ) : ( — )}
) : t.interventions.length ? (
    {t.interventions.map((i, k) => (
  • {humanize(i.type)} {i.name} {i.description ? {i.description} : null}
  • ))}
) : ( No intervention recorded. )}
{t.arms.length || t.primary_outcomes.length ? (

Arms ({t.arms.length})

Primary outcomes ({t.primary_outcomes.length})

{t.secondary_outcomes.length ? (
Secondary outcomes ({t.secondary_outcomes.length})
) : null}
) : null}
{eligText ? (
Show eligibility criteria text
{eligText}
) : Object.keys(elig).length ? (
Show eligibility record
) : (

No eligibility text recorded.

)}
{pubs.length ? ( <> Showing {fmtInt(pp.from)}–{fmtInt(pp.to)} of {fmtInt(pubTotal)} indexed publications citing this registration } /> `/trial/${t.nct_id}${p > 1 ? `?pPage=${p}` : ''}#references`} label="Publication pages" noun="publications" /> ) : null} {t.references.length ? (
    {t.references.map((r, i) => (
  • {r.type ? {r.type} : null} {r.citation ?? ''} {r.pmid ? ( <> {' '} PMID {r.pmid} ) : null}
  • ))}
) : !pubs.length ? ( No reference posted for this study. ) : null}
); }